package com.neusoft.resturant.controller;


import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResCart;
import com.neusoft.resturant.service.IResCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * 购物车Controller
 *
 * @author ruoyi
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/res/cart")
public class ResCartController
{
    @Autowired
    private IResCartService resCartService;

    /**
     * 查询购物车列表
     */

    @GetMapping("/list")
    public R list(ResCart resCart)
    {

        List<ResCart> list = resCartService.selectResCartList(resCart);
        return R.success(list);
    }

    /**
     * 获取购物车详细信息
     */

    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.success(resCartService.selectResCartById(id));
    }

    /**
     * 新增购物车
     */

    @PostMapping
    public R add(@RequestBody ResCart resCart)
    {
        return R.toAjax(resCartService.insertResCart(resCart));
    }

    /**
     * 修改购物车
     */

    @PutMapping
    public R edit(@RequestBody ResCart resCart)
    {
        return R.toAjax(resCartService.updateResCart(resCart));
    }

    /**
     * 删除购物车
     */

	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resCartService.deleteResCartByIds(ids));
    }
}
